feat: add progress callback to surface assessment progress - #235
Open
thunderstornX wants to merge 1 commit into
Open
feat: add progress callback to surface assessment progress#235thunderstornX wants to merge 1 commit into
thunderstornX wants to merge 1 commit into
Conversation
red_team() rendered progress only to the console via rich, so a custom UI (e.g. Streamlit, the use case in confident-ai#173) had no way to display assessment progress. This adds an optional progress callback that emits the same start/advance events to the caller. All progress flows through add_pbar/update_pbar, so a single module-level observer fired from those two choke points covers every progress bar without touching the 30+ attack modules. Exposed as red_team(on_progress=...) and the module-level set_progress_callback(). Backward-compatible (new optional param), and a raising callback is swallowed so it can never break a run. Closes confident-ai#173
|
@thunderstornX is attempting to deploy a commit to the Confident AI Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
red_team()renders progress only to the console (viarich), so a custom UI such as Streamlit (the use case in #173) has no way to display assessment progress. This adds an optional progress callback that streams the samestart/advanceevents to the caller.Implementation
All progress in deepteam flows through two helpers,
add_pbarandupdate_pbar. Rather than thread a callback through the 30+ attack modules that create progress bars, a single module-level observer is invoked from those two choke points, so every progress bar reports through it automatically.Exposed two ways:
red_team(..., on_progress=fn)for the common case (scoped to the run).set_progress_callback(fn)for directRedTeameruse.The callback receives dicts such as:
{"event": "start", "description": "📝 Evaluating ...", "completed": 0, "total": 12} {"event": "advance", "description": "📝 Evaluating ...", "completed": 1, "total": 12}It is fully backward-compatible (new optional argument, defaults to
None), and a raising callback is swallowed so user code can never break an assessment.Example
Testing
tests/test_core/test_progress_callback.pycovering: start/advance events, context-manager scoping and restoration, headless (progress-disabled) emit, and callback-exception isolation. These run against the realrich.Progresspath.red_team()run; the callback received the full event stream across all three phases:tests/test_coreare unaffected, and thered_team()parameter reference in the docs now listson_progress.Closes #173